home *** CD-ROM | disk | FTP | other *** search
- Path: volanj.dayton.saic.com!John_Volan
- From: John G. Volan <John_Volan@ccmail.dayton.saic.com>
- Newsgroups: comp.lang.ada,comp.lang.c++
- Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
- Date: 29 Mar 1996 19:35:27 GMT
- Organization: Science Applications International Corp. (SAIC)
- Distribution: world
- Message-ID: <4jhe1v$m0g@dayuc.dayton.saic.com>
- References: <wnewmanDoxrCp.DKv@netcom.com> <4je9ju$174r@watnews1.watson.ibm.com> <ROGOFF.96Mar28134118@sccm.Stanford.EDU>
- NNTP-Posting-Host: volanj.dayton.saic.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-XXMessage-ID: <AD81984CB5021A68@volanj.dayton.saic.com>
- X-XXDate: Fri, 29 Mar 1996 13:38:20 GMT
-
- In article <315AC5E7.3A77@escmail.orl.mmc.com>
- Ted Dennison, dennison@escmail.orl.mmc.com writes:
-
- >If you want to declare variables later in the code just
- >use a declare block:
- > declare
- > Var1 : My_Type;
- > ...
- > begin
- > Var1 := My_Value;
- > ...
- > end;
- >
- >This has the added benefit of limiting the scope of Var1 to the
- >begin..end block of code.
-
- There is another benefit, but it isn't obvious unless you take into
- account the concurrency aspects of Ada:
-
- A C programmer would complain about having to introduce an extra
- begin/end block in order to introduce variables. Isn't the scope
- of a variable well-defined in C, even without this extra baggage?
- It just extends from the declaration to the end of whatever block
- you're already in.
-
- An Ada programmer would counter that, in Ada, some variables might be
- instances of _task_ types. By definition, a task object gets created
- when its declaration is elaborated, but it does not get _activated_
- (i.e., it doesn't start executing its statements) until you hit the
- "begin" of the enclosing block. This guarantees that everything in the
- enclosing declarative region is elaborated before any a task starts up.
- In fact, _all_ the tasks in a declarative region are activated by the
- "begin", simultaneously. (Or virtually simultaneously. The point is,
- Ada does not prescribe any particular order of activation, and does not
- preclude truly simultaneous activation if the underlying run time
- environment can support it.) In effect, if a declarative region
- contains tasks, then there is a synchronization point at the "begin"
- which the Ada programmer can rely on.
-
- C, of course, has no concurrency abstractions built in (nor does C++,
- last time I checked), so, gee, I guess this isn't an issue in C. :-)
-
- ------------------------------------------------------------------------
- Internet.Usenet.Put_Signature
- ( Name => "John G. Volan", E_Mail => "John_Volan@dayton.saic.com",
- Favorite_Slogan => "Ada95: The *FIRST* International-Standard OOPL",
- Humorous_Disclaimer => "These opinions are undefined by SAIC, so" &
- "any use would be erroneous ... or is that a bounded error now?" );
- ------------------------------------------------------------------------
-